import { setHomeName, setHomeTime } from "../actionTypes";
const defaultState = {
  home: { name: "北工商", year: "20年" },
  about: { title: "走进北工商", content: "欢迎您！" }
};
// 纯函数：没有第三方依赖，不饿能有请求接口，不能有异步方法
export default (state = defaultState, action) => {
  //  默认就克隆好新状态
  let newState = JSON.parse(JSON.stringify(state));
  // 通过动作类型处理新类型
  switch (action.type) {
    case setHomeName:
      // 真正的处理逻辑--修改首页里的name值
      newState.home.name = action.value;
      return newState;
      case setHomeTime:
        newState.home.year = action.value;
        return newState;
    default:
      return state;
  }
};
